<%--
  Created by IntelliJ IDEA.
  User: Dink
  Date: 2022/1/29
  Time: 15:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>修改APP版本信息页面</title>
</head>
<body>
<%@ include file="comment/header.jsp"%>
<div style="position: relative;left: 230px;top:-10px;width: 1270px">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_title">
                    <h3>修改APP版本信息&nbsp;
                        <span class="glyphicon glyphicon-user" aria-hidden="true"></span>&nbsp;${dev}</h3>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <div class="x_title">
                    <p class="text-muted font-13 m-b-30">
                        <h4>历史版本列表</h4>
                    </p>
                    </div>
                    <table id="datatable" class="table table-striped table-bordered">
                        <tr>
                            <td>软件名称</td>
                            <td>版本号</td>
                            <td>版本大小(单位:M)</td>
                            <td>发布状态</td>
                            <td>APK</td>
                            <td>最近更新时间</td>
                        </tr>
                        <c:forEach items="${list}" var="list" varStatus="status">
                            <tr <c:if test="${status.index%2==0}">bgcolor="#f0f8ff" </c:if>>
                                <td>${list.appName}</td>
                                <td>${list.versionNo}</td>
                                <td>${list.versionSize}</td>
                                <td>${list.publishStatusName}</td>
                                <td>${list.apkFileName}</td>
                                <td><f:formatDate value="${list.modifyDate}" pattern="yyyy-MM-dd"/> </td>
                            </tr>
                        </c:forEach>
                    </table>
                </div>
                <form action="${pageContext.request.contextPath}/app_version/update" onsubmit="return regs();" class="form-horizontal form-label-left"  enctype="multipart/form-data" method="post" >
                    <div class="x_title">
                    <p style="font-size: 20px"><span >修改版本信息
                                <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                            </span>
                    </p>
                    </div>
                    <div class="clearfix"></div>
                    <div class="item form-group">
                        <input type="hidden" value="${app_version.id}" name="id">
                        <input type="hidden" value="${app_version.appId}" name="appid">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">版本号<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="name" value="${app_version.versionNo}" disabled class="form-control col-md-7 col-xs-12"   required="required" data-validate-length-range="6" data-validate-words="2" name="versionNo" placeholder="请输入版本号" type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">版本大小 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input  required="required" value="${app_version.versionSize}" type="text" name="versionSize" placeholder="请输入版本大小，单位为MB"  class="form-control col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">发布状态 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            预发布
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">版本介绍 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input  name="versionInfo" value="${app_version.versionInfo}" placeholder="请输入版本相关信息" required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="website">APK文件 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <span id="apkFileName">${app_version.apkFileName}</span>
                            <input name="apkFileName" type="hidden" value="${app_version.apkFileName}">
                            <input name="apkLocPath" type="hidden" value="${app_version.apkLocPath}">
                            <a id="xiazai">下载</a>
                            <a href="javascript:;" onclick="delimg(this);">删除</a>
                            <input type="file" id="website" name="file" class="form-control col-md-7 col-xs-12">
                            <p id="regs"><span style="color: red">*注：格式只能为apk</span></p>
                            <span style="color: red">${fileUploadErro}</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                            <button type="submit" class="btn btn-primary">保存</button>
                            <a href="${pageContext.request.contextPath}/app_info/list">
                                <button id="send" type="button" class="btn btn-success">返回</button></a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<%@ include file="comment/foot.jsp"%>
</body>
<script src="../../statics/js/jquery.js"></script>
<script type="text/javascript">
    function regs() {
        if($("[name=versionNo]").val()==''||$("[name=versionSize]").val()==''
            ||$("[name=versionInfo]").val()==''||$("[name=apkFileName]").val()==''){
            alert("请填写完整所有项！");
            return false;
        }
        if ($("[name=file]").hide()){
            $("form").attr("action","${pageContext.request.contextPath}/app_version/update2")
            return true;
        }
        return true;
    }
$(function () {
    $("[name=file]").hide();
    $("#regs").hide();

});
    function delimg(obj) {
        $("#apkFileName").remove();
        $("#xiazai").remove();
        $(obj).remove();
        alert("删除成功！");
        $("[name=file]").show();
        $("#regs").show();

    }
</script>
</html>
